﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.depinfo
{
    public partial class Modify : Web.Admin.BasePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int depid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(depid);
                }
            }
        }

        private void ShowInfo(int depid)
        {
            lcs.BLL.depinfo bll = new lcs.BLL.depinfo();
            lcs.Model.depinfo model = bll.GetModel(depid);
            this.lbldepid.Text = model.depid.ToString();
            this.txtdepname.Text = model.depname;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtdepname.Text.Trim().Length == 0)
            {
                strErr += "部门名称不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int depid = int.Parse(this.lbldepid.Text);
            string depname = this.txtdepname.Text;


            lcs.Model.depinfo model = new lcs.Model.depinfo();
            model.depid = depid;
            model.depname = depname;

            lcs.BLL.depinfo bll = new lcs.BLL.depinfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "List.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
